//148463fb-52b3-4540-9e1b-740e1f50c47f.sqlite
var EXPORTED_SYMBOLS = ["dk9Sqlite"];
var dk9Sqlite = {
onLoad:function(dbname){
    this.initialized = true;
    this.dbStatus = true;
    var flag=this.dbInit(dbname);
    return flag;
},
initialized:false,
dbStatus:false,
dbConnection:null,

dbInit:function(dbname){
  
  var dirService = Components.classes["@mozilla.org/file/directory_service;1"].
          getService(Components.interfaces.nsIProperties);
  
  //var dbFile = dirService.get("ProfD", Components.interfaces.nsIFile);
  Components.utils.import("resource://gre/modules/FileUtils.jsm");
  var dbFile = FileUtils.getFile("ProfD", [dbname]);
  //alert(dbFile.path);
  var dbService = Components.classes["@mozilla.org/storage/service;1"].
          getService(Components.interfaces.mozIStorageService);
  
  var dbConnection;
  
  if(!dbFile.exists())
   {
      //dbConnection = this._dbCreate(dbService,dbFile);
      return 0;
   }  
  else{
      dbConnection = dbService.openDatabase(dbFile);    
  }
  this.dbConnection = dbConnection;
  return 1;
},

_dbCreate:function(aDBService, aDBFile){
  var dbConnection = aDBService.openDatabase(aDBFile);
  this._dbCreateTables(dbConnection);
  return dbConnection;
},

onClose:function(){
    this.initialized = false;
    this.dbStatus=false;
    this.dbConnection.asyncClose();
}
};